﻿using IdGen;
using Orleans;
using Orleans.Concurrency;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Puppy.CommonService
{
    [Reentrant]
    public class IDGenerateActor : Grain, IIDGenerateActor
    {
        private IdGenerator UnitIdGen { get; } = new IdGenerator(0);

        public ValueTask<long> NewID()
        {
            return ValueTask.FromResult(UnitIdGen.CreateId());
        }

        public ValueTask<IEnumerable<long>> NewIDBatch(int count)
        {
            return ValueTask.FromResult(UnitIdGen.Take(count));
        }
    }
}
